def different(i,arr):
    if(i==len(arr)-1):
        return 0;
    else:
        for j in range(i, len(arr)):
            for k in range(j + 1, len(arr)):
                for l in range(j, k):
                    if (arr[l] == arr[k]):
                        return (k - j);
s=input("请输入一个字符串");
arr=list(s);
list2=[];
for i in range(0,len(arr)):
    list2.append(different(i,arr));
print(max(list2));




